#!/usr/bin/python
# encoding: utf-8
'''
@File    :   code.py
@Time    :   2020/03/11 21:54:19
@Author  :   fangkaijin 
@Version :   1.0
@Contact :   fangkaijin@gmail.com
@License :   杭州移动互联
@Desc    :   None
'''

# 导入库包

import sys, os

from urllib3 import PoolManager

from bs4 import BeautifulSoup
import json
import time

url = 'https://www.baidu.com'

manager = PoolManager(10)
res = manager.request('GET', url)
print(res.status)
html = res.data.decode('utf-8')

soup = BeautifulSoup(html, 'html.parser')
postion = soup.findAll('input')
for p in postion:
    print(p)

urlRoot = 'https://testapi.meishubao.com/'
urlInit = '/api/oss/sts'
#print(''.join(urlRoot).join(urlInit))
param = {}
head = {'identity':'1',
        'timestamp':time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()),
        'sign':'',
        'platform':'Android',
        'User-Agent':'uid',
        'useragent':'',
        'userid':1010,
        'model':'',
        'buildversion':170000,
        'imei':'',
        'channel':'',
        'bundleid':'com.yiqi.onetoone'}
res = manager.request('POST', urlRoot+urlInit, fields=param, headers=head)

class OssSts(object):
    def __init__(self, accessKeyId, securityToken, accessKeySecret, expiration):
        self.accessKeyId = accessKeyId
        self.securityToken = securityToken
        self.accessKeySecret = accessKeySecret
        self.expiration = expiration

    def toString(self):
        print('Oss 参数: accessKeyId: %s, securityToken: %s, accessKeySecret: %s, expiration: %s.' % (self.accessKeyId, self.securityToken, self.accessKeySecret, self.expiration))

def json2Oss(d):
    return OssSts(d.get('accessKeyId'), d.get('securityToken'), d.get('accessKeySecret'), d.get('expiration'))

o = json.loads(res.data, object_hook=json2Oss)
o.toString()


